package cn.bdqn.controller.check;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.bdqn.pojo.Check;
import cn.bdqn.service.check.CheckService;

@Controller
@RequestMapping("/check")
public class CheckController {
	
	@Resource
	private CheckService  chService;

	@RequestMapping("/checklist")
	public String  getCheckList(Model model){
		List<Check> listcheck=chService.getCheckList();
		System.out.println("listcheck======"+listcheck);
		model.addAttribute("listcheck", listcheck);
		return "checklist";
		
	}
	
	@RequestMapping("/addcheck")
	public String addCheck(@ModelAttribute("check") Check check){
		
		return "checkadd";
		
	}
	
	@RequestMapping("/savecheck")
	public String savecheck(Check check){
		int i=chService.addCheck(check);
		if(i>0){
			return "redirect:/check/checklist";
		}
		return "checkadd";
		
	}
	
	
	
}
